package com.neusoft.his.sys.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.neusoft.his.sys.entity.CommonResult;
import com.neusoft.his.sys.entity.Dept;
import com.neusoft.his.sys.service.IDeptService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 东软教育集团
 * @since 2022-08-24
 */
@RestController
@RequestMapping("/dept")
@CrossOrigin("*")
public class DeptController {
	@Autowired
	IDeptService deptService;
//	http://127.0.0.1:18080/his/dept/mod
	@PostMapping("/mod")
	public CommonResult modDept(@RequestBody Dept dept) {
		CommonResult result = deptService.modDept(dept);
		return result;
		
	}
	
	
	
//	/dept/add
	@PutMapping("/add")
	public CommonResult addDept(@RequestBody Dept dept) {
		CommonResult result = deptService.addDept(dept);
		return result;
	}
	
	
	
	
//	根据deptno删除部门对象
//	/dept/10
	@DeleteMapping("/{deptno}")
	public CommonResult delById( @PathVariable("deptno") int deptno ){
		CommonResult result =  deptService.delById(deptno);
		return deptService.getAll();
	}
// 获得所有的部门信息列表
	@GetMapping("/all")
	public CommonResult getAll(){
		return deptService.getAll();
	}
	 

}
